package com.ftg.learn.controller;

import com.ftg.learn.pojo.Car;
        import com.ftg.learn.service.CarService;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.*;

        import java.util.HashMap;
        import java.util.List;
        import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/car")
//汽车
public class CarController {
    @Autowired
    CarService cs;
    @GetMapping("/show")
    public Map<String,Object> showall(int page,int limit){
        Map<String,Object> map = new HashMap<>();
        List<Car> list = cs.showall(page,limit);
        map.put("data",list);
        map.put("code",0);
        map.put("count",cs.getcount());
        map.put("msg","到哪里");
        return map;

    }
    //查一
    @PutMapping("/findone")
    public List<Car> findone(String car_id, String car_name){
        return cs.findone(car_id,car_name);
    }
    //添加
    @PutMapping("/add")
    public List<Car> add(Car car){
        return cs.add(car);
    }
    //删除
    @DeleteMapping("/delete/{car_id}")
    public int delete(@PathVariable String car_id){
        return cs.delete(car_id);
    }
    //修改
    @PostMapping("/update")
    public int update(Car car){
        return cs.update(car);
    }

}